﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace msBsc.WebUi.wMall.Public
{
    public partial class wfChangePassword1 : msBsc.Cls.BPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        private void changePassword()
        {
            string stremkey = this.GetParamHtValue("KEY");
            if (stremkey != string.Empty)
            {
                if (stremkey == string.Empty)
                {
                    return;
                }
                stremkey = msBsc.AppLogic.Cfg.DesCry.uncMe(stremkey, "rmdes");
                string[] arrten = stremkey.Split(',');
                if (arrten.Length < 2)
                {
                    //this.ExecJScript("window.location.href = '/c_RegMailSend.htm';");提示错误链接失效
                    return;
                }
                if (Convert.ToDateTime(arrten[1])<DateTime.Now)
                {
                    this.Alert("验证过期，请重新获取修改路径");
                    return;
                }
                string password = this.GetParamHtValue("password");
                if (string.IsNullOrEmpty(password))
                {
                    this.Alert("密码不能为空");
                    return;
                }
                string okPassword = this.GetParamHtValue("okPassword");
                if (password!=okPassword)
                {
                    this.Alert("两次密码不一致");
                    return;
                }
                using (msBsc.AppLogic.DataAlc.CBizCustomerRegister register = new AppLogic.DataAlc.CBizCustomerRegister())
                {
                    string[] retArry = register.EditUserPassword(arrten[0], password);
                    if (retArry[0] != "TRUE")
                    {
                        this.Alert(retArry[1]);
                        return;
                    }
                    else 
                    {
                        this.ExecJScript(@"firstNext(2);");
                    }
                }
            }
        }

        public override void DoAction()
        {
            if (this.strAction=="doChangePassword")
            {
                changePassword();
            }
        }
    }
}